

#include <stdio.h>
#include <stdlib.h>

#include <pthread.h>

int main(int argc, char **argv){
  char cmd[500];
  FILE * pFile;
  char buff[1024];
  int sec;

if(argc!=4){

  printf("sendtoque <device> <number> <seconds to hang up>\r\n");

  printf("ie: sendtoque /dev/ttyUSB0 911111111 10\r\n");

}else{

  sprintf(cmd,"ATD%s;\r\n",argv[2]);


  pFile = fopen (argv[1],"w");
  if (pFile!=NULL)
  {
    fputs (cmd,pFile);


    sec=atoi(argv[3]);

    sleep(sec);

    fputs("AT+CHUP\r\n",pFile);

    fclose(pFile);

    sleep(3);

    pFile = fopen (argv[1],"r");


    //fgets(buff,1024 , pFile);
    //printf("%s", buff);

    //fgets(buff,1024 , pFile);
    //printf("%s", buff);    
    
    fclose (pFile);



  }
}

  return 0;


}
